{extend name="wap/default_new/base" /}
{block name="resources"}
<style>
body {
    background-color: #fff;
}
ul {
    padding-left: 10px;
    padding-right: 10px;
}
ul li {
    padding-top: 5px;
    padding-bottom: 5px;
    border-bottom: 1px solid #ddd;
}
.box-title {
    color: #000;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    font-size: 15px;
}
.box-time {
    font-size: 13px;
    color: rgb(168, 168, 168);
}
</style>
{/block}
{block name="goodsHead"}
<section class="head">
	<a class="head_back" href="{:__URL('APP_MAIN/')}"><i class="icon-back"></i></a>
	<div class="head-title"><span style="margin-left: 5%;">公告列表</span></div>
</section>
<div style="height: 45px;"></div>
{/block}
{block name="main"}
<div class="custom-tag-list-goods wenzhang_list" id="article_list">

</div>

<input type="hidden" id="page" value="1">
<input type="hidden" id="page_count" value="0">
<script>
$(function(){
	var class_id = $("#class_id").val();
	getArticleList(1);
})


var is_load =true;
function getArticleList(page){
	if(is_load){
		is_load = false;
		$.ajax({
			type:"post",
			url : "{:__URL('APP_MAIN/index/noticeList')}",
			async : true,
			data : {'page':page },
			success : function(data){
				$("#page_count").val(data['page_count']);
				if(page == 1){
					var article_list_html = '';
				}else if(page > 1){
					var article_list_html = $('#article_list').html();
				}
				if(data['data'].length >0 ){
					article_list_html +='<ul>';
					for(var i =0 ;i<data['data'].length;i++){
						article_list_html +='<li>';
						article_list_html +='<p class="box-title"><a href="'+__URL('APP_MAIN/index/noticecontent?id='+data['data'][i]['id'])+'">'+data['data'][i]['notice_title']+'</a></p>';
						article_list_html +='<p class="box-time">'+timeStampTurnTime(data['data'][i]['create_time'])+'</p>';
						article_list_html +='</li>';
					}
					article_list_html +='</ul>';
				}else{
					article_list_html+= '<p style="color:#939393;text-align:center;margin-top:100px;"><img src="__TEMP__/{$style}/public/images/wap_nodata.png" height="100"><br>暂时没有公告！</p>';
				}
				$('#article_list').html(article_list_html);
				is_load =true;
			}
		})
	}	
}

//滑动到底部加载
$(window).scroll(function(){
	var totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());
	var content_box_height = parseFloat($("#article_list").height()); 
	if(totalheight - content_box_height >= 40){
		if(is_load){
			var page = parseInt($("#page").val()) + 1;//页数
			var total_page_count = $("#page_count").val(); // 总页数
			var class_id = $("#class_id").val();
			if(page > total_page_count){
				return false;
			}else{
				getArticleList(class_id,page);
			}
		}
		
	}
})
</script>
{/block}
{block name="bottom"} {/block}